package com.bluegalaxy.nhb.snapi.core.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;

/**
 * Created by IntelliJ IDEA.
 *
 * @author: 大雄
 * @date: 2019-08-07
 * @time: 15:56
 * @description: To change this template use File | Settings | File Templates.
 */
@Component
@Configuration
public class AdminMvcConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new XxInterceptor())
                .excludePathPatterns("/public/**")
                .excludePathPatterns("/login/*")
                .excludePathPatterns("/captcha")
                .excludePathPatterns("/errorBrowser")
                .excludePathPatterns("/loginValidate")
                .excludePathPatterns("/portal/**")
                .addPathPatterns("/**");

        //添加字符集参数
        LocaleChangeInterceptor localeInterceptor = new LocaleChangeInterceptor();
        localeInterceptor.setParamName("lang");
        registry.addInterceptor(localeInterceptor);
    }
}
